<template lang="pug">
    skin(@up="up",@down="down",@yes="yes",@back="back",@duringUp="up",@duringDown="down")
        div(class="flex-column large-dose-common h3")
            div(class="flex-column-item flex-center-center")
                span ----手动大剂量-----

            div(class="flex-column-item flex-center")
              div(class="flex-row")
                div(class="flex-row-item flex-3")
                  span(class="iconfont") &#xe62c;
                  span 开始输注:
                div(class="flex-row-item right")
                  control-amount(v-model="amount",:working="true",ref="ref")
                div(class="flex-row-item right flex-0")
                   span u


            div(class="flex-column-item flex-center")
                div(class="flex-row")
                  div(class="flex-row-item flex-3")
                    span 当日已输注
                  div(class="flex-row-item right")
                    span {{hasInfusionAmount | fixed}}
                  div(class="flex-row-item right flex-0")
                    span u


            div(class="flex-column-item flex-center")
                div(class="flex-row")
                  div(class="flex-row-item flex-3")
                    span 日总量限制
                  div(class="flex-row-item right")
                    span {{dayLimit}}
                  div(class="flex-row-item right flex-0")
                    span u

</template>

<script>
    import dayjs from "dayjs";
    import Base from '@/mixins/BaseVue'

    export default {
        mixins:[Base],
        data() {
            return {
                visible: false,
                lastInfusion: [],
                hasInfusion: false,
                plan: {amount: null},
                meal: null,
                amount: {
                    value: {name: 0, value: 0},
                    min: 0,
                    max: 20,
                    increment: 0.1
                },
                dayLimit: window.dose.dayLimit
            };
        },
        computed:{

            hasInfusionAmount(){
                let result = 0;
                const today = dayjs().format('YYYYMMDD');
                window.dose.records.forEach((record, index) => {
                    if(dayjs(record.date).format('YYYYMMDD') == today)
                        result =( result * 10 + record.amount * 10 ) / 10
                })

                return result;
            }

        },
        methods: {

            up() {
               this.$refs.ref.up();
            },
            down() {
                this.$refs.ref.down();
            },

            back() {
                if (this.visible) {
                    this.visible = false;
                }
                else {
                    this.$router.push("/large-dose/menu?index=0");
                }
            },
            yes() {
                if (this.amount.value.value > 0) {
                    this.$router.push("commonSure?amount=" + this.amount.value.value);
                }
            }
        }
    };
</script>

<style lang="less">
</style>
